#include "FactoryEntity.h"

FactoryEntity::FactoryEntity()
{

}

void FactoryEntity::add(std::string s, Entity* e)
{
    if(factory.count(s))
        std::cerr << "[WARNING] Redefinition of '" << s << "' in the factory." << std::endl;

    factory[s] = e;
}

Entity* FactoryEntity::create(std::string s)
{
    if(!factory.count(s))
        throw std::logic_error("[ERROR] The entry '" + s + "' does not belong to the factory.");

    return factory[s]->clone();
}

FactoryEntity::~FactoryEntity()
{

}
